function tau(tau_out, parms, q, dq, ddq)
#
    x0 = -ddq[1]
    x1 = sin(q[2])
    x2 = -dq[1]
    x3 = cos(q[2])
    x4 = -x3
    x5 = x2*x4
    x6 = -x5
    x7 = dq[2]*x6 + x0*x1
    x8 = x1*x2
    x9 = dq[2]*x8 + x0*x4
    x10 = dq[2]*parms[17] + parms[15]*x8 + parms[18]*x5
    x11 = 9.81*x3
    x12 = cos(q[3])
    x13 = sin(q[3])
    x14 = ddq[2]*x13
    x15 = x12*x7
    x16 = dq[2]*x12
    x17 = x13*x8
    x18 = -x17
    x19 = x16 + x18
    x20 = -dq[3]
    x21 = -x20
    x22 = x14 + x15 + x19*x21
    x23 = -ddq[3] - x9
    x24 = ddq[2]*x12
    x25 = x13*x7
    x26 = -x25
    x27 = dq[2]*x13
    x28 = x12*x8
    x29 = x27 + x28
    x30 = x20*x29 + x24 + x26
    x31 = 0.045*x12^2 + 0.045*x13^2
    x32 = -x13
    x33 = -9.81*x1
    x34 = 0.55*x16 - 0.55*x17
    x35 = 0.045*ddq[3] - 0.55*x14 - 0.55*x15 + x20*x34 + x31*x9 + x32*x33
    x36 = x16*x31 + x18*x31
    x37 = -0.55*x27 - 0.55*x28 + x31*x5
    x38 = 0.045*dq[3]
    x39 = x37 + x38
    x40 = x20 + x6
    x41 = -parms[31]
    x42 = parms[32]*x29 + parms[34]*x39 + x40*x41
    x43 = -parms[32]
    x44 = parms[27]*x29 + parms[29]*x40 + parms[30]*x19 + parms[31]*x36 + x34*x43
    x45 = cos(q[4])
    x46 = sin(q[4])
    x47 = -dq[4]
    x48 = x29*x46
    x49 = -x45
    x50 = x40*x49
    x51 = x48 + x50
    x52 = x22*x45 + x23*x46 + x47*x51
    x53 = ddq[4] + x30
    x54 = x22*x46
    x55 = x23*x49
    x56 = x29*x45 + x40*x46
    x57 = dq[4]*x56 + x54 + x55
    x58 = x45^2
    x59 = x46^2
    x60 = 0.045*x58 + 0.045*x59
    x61 = x12*x33 + x21*x37 + 0.55*x24 - 0.55*x25 + x38*x6
    x62 = -x11
    x63 = -x29
    x64 = x24*x31 + x26*x31 + x38*x63 + x62
    x65 = x34*x45 + x36*x46
    x66 = 0.045*ddq[4] + dq[4]*x65 + x30*x60 + x46*x61 + x49*x64
    x67 = dq[4] + x19
    x68 = -0.045*x58 - 0.045*x59
    x69 = x39 + x48*x68 + x50*x68
    x70 = -x65
    x71 = parms[39]*x56 + parms[41]*x67 + parms[42]*x51 + parms[43]*x69 + parms[44]*x70
    x72 = cos(q[5])
    x73 = x52*x72
    x74 = sin(q[5])
    x75 = x53*x74
    x76 = x67*x72
    x77 = -x56
    x78 = x74*x77 + x76
    x79 = -dq[5]
    x80 = -x79
    x81 = x73 + x75 + x78*x80
    x82 = -x57
    x83 = -ddq[5] + x82
    x84 = x53*x72
    x85 = -x74
    x86 = x67*x74
    x87 = x56*x72
    x88 = x86 + x87
    x89 = x52*x85 + x79*x88 + x84
    x90 = 0.045*dq[4]
    x91 = x35 + x54*x68 + x55*x68 + x77*x90
    x92 = x19*x60 + x34*x46 + x36*x49
    x93 = x19*x90 + x45*x61 + x46*x64 + x47*x92
    x94 = -0.3*x74
    x95 = x56*x94 + x65*x72 + x69*x74 + 0.3*x76
    x96 = x72*x91 - 0.3*x73 - 0.3*x75 + x79*x95 + x85*x93
    x97 = x90 + x92
    x98 = -x97
    x99 = x65*x85 + x69*x72 - 0.3*x86 - 0.3*x87
    x100 = -x51
    x101 = x100 + x79
    x102 = -parms[55]
    x103 = parms[56]*x88 + parms[58]*x99 + x101*x102
    x104 = -parms[56]
    x105 = parms[51]*x88 + parms[53]*x101 + parms[54]*x78 + parms[55]*x98 + x104*x95
    x106 = cos(q[6])
    x107 = sin(q[6])
    x108 = -x106
    x109 = x101*x108 + x107*x88
    x110 = -dq[6]
    x111 = x106*x81 + x107*x83 + x109*x110
    x112 = ddq[6] + x89
    x113 = x101*x107 + x106*x88
    x114 = dq[6]*x113 + x107*x81 + x108*x83
    x115 = x52*x94 + x72*x93 + x74*x91 + x80*x99 + 0.3*x84
    x116 = -x66
    x117 = x106*x95 + x107*x98
    x118 = dq[6]*x117 + x107*x115 + x108*x116
    x119 = x107*x95 + x108*x98
    x120 = dq[6] + x78
    x121 = -parms[67]
    x122 = parms[68]*x113 + parms[70]*x119 + x120*x121
    x123 = -parms[68]
    x124 = parms[63]*x113 + parms[65]*x120 + parms[66]*x109 + parms[67]*x99 + x117*x123
    x125 = cos(q[7])
    x126 = x111*x125
    x127 = sin(q[7])
    x128 = x112*x127
    x129 = x120*x125
    x130 = x113*x127
    x131 = x129 - x130
    x132 = dq[7]*x131 + x126 + x128
    x133 = x112*x125
    x134 = -x127
    x135 = x113*x125
    x136 = x120*x127
    x137 = x135 + x136
    x138 = -dq[7]
    x139 = x111*x134 + x133 + x137*x138
    x140 = ddq[7] + x114
    x141 = dq[7] + x109
    x142 = x117*x134 + x125*x99 - 0.06*x135 - 0.06*x136
    x143 = x117*x125 + x127*x99 + 0.06*x129 - 0.06*x130
    x144 = -parms[80]
    x145 = parms[75]*x137 + parms[77]*x131 + parms[78]*x141 + parms[79]*x142 + x143*x144
    x146 = -parms[79]
    x147 = parms[80]*x137 + parms[82]*x119 + x131*x146
    x148 = x106*x115 + x107*x116 + x110*x119
    x149 = x125*x96 - 0.06*x126 - 0.06*x128 + x134*x148 + x138*x143
    x150 = -parms[81]
    x151 = parms[79]*x141 + parms[82]*x142 + x137*x150
    x152 = -x151
    x153 = parms[74]*x137 + parms[76]*x131 + parms[77]*x141 + parms[81]*x143 + x119*x146
    x154 = parms[73]*x132 + parms[74]*x139 + parms[75]*x140 + parms[80]*x118 + x119*x152 + x131*x145 - x141*x153 + x142*x147 + x149*x150
    x155 = -parms[69]
    x156 = parms[62]*x113 + parms[64]*x120 + parms[65]*x109 + parms[69]*x117 + x119*x121
    x157 = -x109
    x158 = parms[67]*x109 + parms[70]*x99 + x113*x155
    x159 = -0.06*x127
    x160 = dq[7]*x142 + x111*x159 + x125*x148 + x127*x96 + 0.06*x133
    x161 = parms[81]*x131 + parms[82]*x143 + x141*x144
    x162 = parms[73]*x137 + parms[74]*x131 + parms[75]*x141 + parms[80]*x119 + x142*x150
    x163 = -x137
    x164 = parms[74]*x132 + parms[76]*x139 + parms[77]*x140 + parms[81]*x160 + x118*x146 + x119*x161 + x141*x162 - x143*x147 + x145*x163
    x165 = parms[81]*x139 + parms[82]*x160 + x131*x147 + x140*x144 + x141*x152
    x166 = parms[79]*x140 + parms[82]*x149 + x132*x150 + x141*x161 + x147*x163
    x167 = x125*x166
    x168 = parms[61]*x111 + parms[62]*x112 + parms[63]*x114 + parms[68]*x118 - x119*x158 + x120*x124 + x122*x99 + x125*x154 + x134*x164 + x155*x96 + x156*x157 + x159*x165 - 0.06*x167
    x169 = -x131
    x170 = parms[75]*x132 + parms[77]*x139 + parms[78]*x140 + parms[79]*x149 + x137*x153 - x142*x161 + x143*x151 + x144*x160 + x162*x169
    x171 = parms[69]*x120 + parms[70]*x117 + x109*x123
    x172 = -x171
    x173 = parms[61]*x113 + parms[62]*x120 + parms[63]*x109 + parms[68]*x119 + x155*x99
    x174 = parms[63]*x111 + parms[65]*x112 + parms[66]*x114 + parms[67]*x96 + x113*x156 + x117*x158 - x120*x173 + x123*x148 + x170 + x172*x99
    x175 = -parms[57]
    x176 = parms[50]*x88 + parms[52]*x101 + parms[53]*x78 + parms[57]*x95 + x102*x99
    x177 = -x78
    x178 = parms[55]*x78 + parms[58]*x98 + x175*x88
    x179 = parms[49]*x81 + parms[50]*x83 + parms[51]*x89 + parms[56]*x96 + x101*x105 + x103*x98 + x106*x168 + x107*x174 + x116*x175 + x176*x177 - x178*x99
    x180 = -x67
    x181 = parms[43]*x180 + parms[44]*x56 + parms[46]*x97
    x182 = -parms[45]
    x183 = parms[43]*x51 + parms[45]*x77 + parms[46]*x69
    x184 = -x113
    x185 = x125*x165
    x186 = parms[62]*x111 + parms[64]*x112 + parms[65]*x114 + parms[69]*x148 + x109*x173 - x117*x122 + x118*x121 + x119*x171 + x124*x184 + x125*x164 + x127*x154 + x159*x166 + 0.06*x185
    x187 = parms[57]*x101 + parms[58]*x95 + x104*x78
    x188 = -x187
    x189 = parms[49]*x88 + parms[50]*x101 + parms[51]*x78 + parms[56]*x99 + x175*x98
    x190 = parms[51]*x81 + parms[53]*x83 + parms[54]*x89 + parms[55]*x116 - x101*x189 + x104*x115 + x176*x88 + x178*x95 + x186 + x188*x98
    x191 = parms[38]*x56 + parms[40]*x67 + parms[41]*x51 + parms[43]*x98 + parms[45]*x65
    x192 = parms[69]*x112 + parms[70]*x148 + x114*x123 + x120*x122 + x134*x166 + x157*x158 + x185
    x193 = parms[68]*x111 + parms[70]*x118 + parms[80]*x132 + parms[82]*x118 + x112*x121 + x113*x158 + x120*x172 + x137*x151 + x139*x146 + x161*x169
    x194 = parms[57]*x83 + parms[58]*x115 + x101*x103 + x104*x89 + x106*x192 + x107*x193 + x177*x178
    x195 = parms[56]*x81 + parms[58]*x96 + parms[67]*x114 + parms[70]*x96 + x101*x188 + x102*x83 + x109*x171 + x111*x155 + x122*x184 + x127*x165 + x167 + x178*x88
    x196 = x195*x72
    x197 = parms[37]*x52 + parms[38]*x53 + parms[39]*x57 + parms[44]*x66 + x100*x191 + x179*x72 + x181*x69 + x182*x91 + x183*x98 + x190*x85 + x194*x94 - 0.3*x196 + x67*x71
    x198 = -x88
    x199 = -parms[50]*x81 - parms[52]*x83 - parms[53]*x89 - parms[57]*x115 - x102*x96 + x103*x95 - x105*x198 - x107*x168 - x108*x174 - x187*x99 - x189*x78
    x200 = parms[37]*x56 + parms[38]*x67 + parms[39]*x51 + parms[44]*x97 + x182*x69
    x201 = parms[44]*x100 + parms[45]*x67 + parms[46]*x65
    x202 = parms[39]*x52 + parms[41]*x53 + parms[42]*x57 + parms[43]*x91 - parms[44]*x93 + x180*x200 + x183*x65 + x191*x56 + x199 - x201*x69
    x203 = -parms[33]
    x204 = parms[26]*x29 + parms[28]*x40 + parms[29]*x19 + parms[33]*x34 + x39*x41
    x205 = -x19
    x206 = parms[31]*x19 + parms[33]*x63 + parms[34]*x36
    x207 = parms[43]*x57 + parms[46]*x91 + x181*x77 + x182*x52 + x194*x74 + x196 + x201*x51
    x208 = x207*x68
    x209 = parms[25]*x22 + parms[26]*x23 + parms[27]*x30 + parms[32]*x35 + x197*x45 + x202*x46 + x203*x64 + x204*x205 - x206*x39 + x208*x46 + x36*x42 + x40*x44
    x210 = dq[2]*parms[16] + parms[14]*x8 + parms[17]*x5
    x211 = x194*x72
    x212 = parms[38]*x52 + parms[40]*x53 + parms[41]*x57 + parms[43]*x116 + parms[45]*x93 + x179*x74 + x181*x70 + x190*x72 + x195*x94 + x200*x51 + x201*x97 + 0.3*x211 + x71*x77
    x213 = -parms[43]*x53 + parms[44]*x52 + parms[46]*x66 - parms[55]*x89 - parms[58]*x116 - x103*x198 - x107*x192 - x108*x193 - x175*x81 + x180*x201 + x183*x56 - x187*x78
    x214 = parms[33]*x40 + parms[34]*x34 + x19*x43
    x215 = -x214
    x216 = parms[25]*x29 + parms[26]*x40 + parms[27]*x19 + parms[32]*x39 + x203*x36
    x217 = parms[27]*x22 + parms[29]*x23 + parms[30]*x30 + parms[31]*x64 + x204*x29 + x206*x34 + x212 + x213*x60 + x215*x36 - x216*x40 + x43*x61
    x218 = parms[44]*x82 + parms[45]*x53 + parms[46]*x93 + x100*x183 + x181*x67 + x195*x85 + x211
    x219 = parms[33]*x23 + parms[34]*x61 + x205*x206 + x213*x46 + x218*x45 + x30*x43 + x40*x42
    x220 = -0.55*x13
    x221 = parms[32]*x22 + parms[34]*x35 + x206*x29 + x207 + x215*x40 + x23*x41
    x222 = x31*(parms[31]*x30 + parms[34]*x64 + x19*x214 + x203*x22 + x213*x49 + x218*x46 + x42*x63)
    x223 = -parms[26]*x22 - parms[28]*x23 - parms[29]*x30 - parms[33]*x61 - x19*x216 - x197*x46 - x202*x49 - x208*x49 - x214*x39 + x34*x42 - x35*x41 - x44*x63
    x224 = dq[2]*parms[14] + parms[13]*x8 + parms[15]*x5
#
    tau_out[1] = dq[1]*parms[11] + parms[12]*sign(dq[1]) - parms[4]*x0 - x1*(ddq[2]*parms[14] + dq[2]*x10 + parms[13]*x7 + parms[15]*x9 + parms[20]*x11 + x12*x209 - 0.55*x12*x221 + x210*x6 + x217*x32 + x219*x220 + x222*x32) - x4*(ddq[2]*parms[17] - dq[2]*x224 + parms[15]*x7 + parms[18]*x9 - parms[20]*x33 + x210*x8 + x221*x31 + x223)
    tau_out[2] = ddq[2]*parms[16] + dq[2]*parms[23] + parms[14]*x7 + parms[17]*x9 + parms[19]*x62 + parms[21]*x33 + parms[24]*sign(dq[2]) - x10*x8 + x12*x217 + 0.55*x12*x219 + x12*x222 + x13*x209 + x220*x221 + x224*x5
    tau_out[3] = dq[3]*parms[35] + parms[36]*sign(dq[3]) + 0.045*x221 + x223
    tau_out[4] = dq[4]*parms[47] + parms[48]*sign(dq[4]) + x212 + 0.045*x213
    tau_out[5] = dq[5]*parms[59] + parms[60]*sign(dq[5]) + x199
    tau_out[6] = dq[6]*parms[71] + parms[72]*sign(dq[6]) + x186
    tau_out[7] = dq[7]*parms[83] + parms[84]*sign(dq[7]) + x170
#
    return tau_out
end